/*
 * @Author: 专送Pro
 * @Date: 2019-08-23 13:17:18
 * @LastEditors  : wuzhen
 * @LastEditTime : 2020-01-11 16:21:03
 * @Description: 配置文件
 */
/* eslint-disable */
import { delMessageRecord } from "@/request/api";
export default {
  data() {
    return {
      // 搜索参数配置
      searchProps: [
        {
          label: "发送人ID",
          type: "number",
          key: "fromid",
          placeholder: "请输入发送人ID"
        },
        {
          label: "接收人ID",
          type: "number",
          key: "targetid",
          placeholder: "请输入接收人ID"
        },
        {
          label: "关键词",
          type: "text",
          key: "content",
          placeholder: "请输入消息内容关键词"
        },
        {
          label: "发送时间",
          type: "daterange",
          key: "date",
          placeholder: "请选择发送时间"
        }
      ],
      columns: [
        {
          type: "selection",
          width: 60
        },
        {
          title: "发送者ID",
          key: "fromid",
          width: 120
        },
        {
          title: "发送者",
          key: "fromname",
          width: 120
        },
        {
          title: "接收者ID",
          key: "targetid",
          width: 120
        },
        {
          title: "接收者",
          key: "targetname",
          width: 120
        },
        {
          title: "发送时间",
          width: 170,
          render: (h, params) => {
            const row = params.row;
            return h("span", this.$fmtMoment(row.createtime));
          }
        },
        {
          title: "　",
          width: 30,
          render: (h, params) => {
            const row = params.row;
            const color = [
              "#999",
              "#f5222d",
              "#fadb14",
              "#eb2f96",
              "#fa541c",
              "#fa8c16",
              "#faad14",
              "#13c2c2",
              "#722ed1",
              "#2f54eb"
            ];
            return h(
              "wz-icon",
              {
                props: {
                  name: `fa-${row.msgtype}`,
                  scale: "1.5"
                },
                style: {
                  color: color[row.msgtype - 1001]
                }
              },
              row.msgtype === 1001
                ? "文字消息"
                : row.msgtype === 1002
                ? "语音消息 "
                : row.msgtype === 1003
                ? "文件类的消息"
                : row.msgtype === 1004
                ? "视频消息"
                : row.msgtype === 1005
                ? "位置消息"
                : row.msgtype === 1006
                ? "图文消息"
                : row.msgtype === 1007
                ? "群聊自定义消息"
                : row.msgtype === 1008
                ? "文件类分享转发"
                : row.msgtype === 1009
                ? "音频消息"
                : row.msgtype === 1010
                ? "图片消息"
                : "--"
            );
          }
        },
        {
          title: "消息内容",
          tooltip: true,
          render(h, params) {
            const row = params.row;
            const strObj = JSON.parse(row.content);
            let content;
            switch (row.msgtype) {
              case 1001:
                content = strObj.content;
                break;
              case 1002:
                content = strObj.fileUrl;
              case 1003:
                content = strObj.fileUrl;
              case 1004:
                content = strObj.fileUrl;
                break;
              case 1009:
                content = strObj.fileUrl;
                break;
              case 1010:
                content = strObj.fileUrl;
                break;
              default:
                break;
            }
            return h(
              "Tooltip",
              {
                props: {
                  content: content,
                  maxWidth: 600
                },
                class: {
                  tabTooltips: true
                }
              },
              [
                h(
                  row.msgtype !== 1001 ? "a" : "span",
                  {
                    attrs: {
                      href: content,
                      target: "_bank"
                    }
                  },
                  content
                )
              ]
            );
          }
        },
        {
          title: "操作",
          width: 160,
          render: (h, params) => {
            const row = params.row;
            return h(
              "span",
              {
                class: {
                  error: true
                },
                on: {
                  click: async () => {
                    this.messageids = [row.messageid];
                    this.onDelete();
                  }
                }
              },
              "删除"
            );
          }
        }
      ]
    };
  }
};
